package com.boguan.device.mapper;

import com.boguan.common.core.domain.entity.SysUser;
import com.boguan.device.domain.Device;
import com.boguan.device.domain.DeviceAlarmLog;
import com.boguan.device.domain.DeviceParam;
import com.boguan.device.domain.DeviceParamVo;
import com.boguan.device.domain.dto.AddGroupDto;
import com.boguan.device.domain.dto.AlarmHistoryDto;
import com.boguan.device.domain.dto.DeviceInfoDto;
import com.boguan.device.domain.dto.DeviceSearchDto;
import com.boguan.device.domain.vo.*;
import org.apache.ibatis.annotations.Param;

import java.util.List;
import java.util.Map;


/**
 * 设备表 数据层
 *
 * @author chen
 */
public interface DeviceMapper {
    int deleteByPrimaryKey(Long deviceId);

    int insert(Device record);

    int insertSelective(Device record);

    Device selectByPrimaryKey(Long deviceId);

    int updateByPrimaryKeySelective(Device record);

    int updateByPrimaryKey(Device record);

    List<Device> selectDeviceByTypeId(Long typeId);

    Device checkDeviceByDeviceNum(Device device);

    List<Device> searchPage(Device device);

    List<DeviceParam> selectParamByParamTypeAndDeviceId(@Param("paramType") Integer paramType, @Param("deviceId") Long deviceId);

    DeviceParamVo selectParamVoByParamTypeAndDeviceId(@Param("paramType") Integer paramType, @Param("deviceId") Long deviceId);

    Integer deviceCount(SysUser user);

    List<Map<String, Integer>> deviceOnlineCount(SysUser user);


    List<Map<String, Object>> subordinateDeviceCount(SysUser user);

    List<Map<String, Object>> typeDeviceCount(SysUser user);

    /**
     * 只查询非网关的设备
     *
     * @param deviceNum
     * @param addr
     * @return
     */
    Device selectByDeviceNum(@Param("deviceNum") String deviceNum, @Param("addr") Integer addr);

    List<DeviceNumBySite> selectDeviceNumBySite(DeviceNumBySite deviceNumBySite);

    Device selectChildDeviceByParentIdAndAddr(@Param("parentId") Long parentId, @Param("addr") Integer addr);

    List<Device> selectChildDeviceByParentId(Long parentId);

    int updateOnlineStatusByParentId(@Param("parentId") Long parentId, @Param("onlineStatus") Integer onlineStatus);

    int updateChildDevice(Device device);

    List<DeviceListVo> getAllDeviceList(@Param("deptId") Long deptId);

    List<DeviceListVo> searchDeviceName(DeviceSearchDto dto);

    int insertDevice(DeviceInfoDto dto);

    List<DeviceDetailVo> deviceDetail(String id);

    List<DeviceDetailAlarmVo>  deviceAlarmDetail(String id);

    List<DeviceDetailAlarmVo> deviceAlarmManage(@Param("device_num") String device_num,@Param("device_name")String device_name,@Param("status") String status);

    List<DeviceDetailAlarmVo> deviceAlarmManageDetail(@Param("device_id") String deviceId,@Param("alarm_time")String alarmTime);

    List<DeviceGroupChildVo> deviceGroup(@Param("id") String id,@Param("group_name")String group_name );

    List<DeviceGroupVo> deviceGroupDetail(Integer id);

    int deviceGroupEdit(@Param("group_name")String group_name,@Param("id")String id);

    int createDeviceGroup(AddGroupDto dto);


    int addToDeviceGroup(@Param("deviceId") String deviceId,@Param("groupId")String groupId);

    int deviceModify(@Param("device_id")String device_id,@Param("device_name")String device_name);


    int deleteDeviceGroupId(String group_id);

    int deleteDeviceGroup(String id);

    List<AddGroupDto> getGroupName();

    List<DeviceAlarmCountVo>  countDeviceAlarm(String id);

    int deleteDeviceFromGroup(String id);

    List<DeviceAlarmCountVo> deviceDetailAlarmHistory(AlarmHistoryDto dto);

    int deviceDelete(String id);

    String online();

    String offline();

    List<DeviceUseVo> deviceUseTimes();

    List<DeviceErrorVo> deviceErrorAlarms();

    List<DeviceListVo> checkDeviceNum(String device_num);

    int deviceToGroup(@Param("group_id") String group_id,@Param("device_id")String device_id);

    void  insertDeviceData(DeviceListVo deviceListVo);


    List<DeviceAlarmCountVo> historyData(String id);

    void updateDeviceInfo (DeviceListVo deviceListVo);

    void insertDeviceInfo(@Param("device_id") Long device_id);

    void insertAlarmLog(DeviceAlarmLog deviceAlarmLog);






}